from common.base_page import BasePage

from appium.webdriver.common.appiumby import AppiumBy
from time import sleep


class PostingPage(BasePage):
    #返回按钮
    # btn_back=(AppiumBy.ID,'com.jhss.youguu:id/btn_back')
    '''点击聊股'''

    btn_desktop_talk = (AppiumBy.ID, 'com.jhss.youguu:id/btn_desktop_talk')
    '''点击铅笔按钮'''
    iv_public_twitter = (AppiumBy.ID, 'com.jhss.youguu:id/iv_public_twitter')
    ''''点击优顾大家谈'''    '''53,898'''
    bar_name=(AppiumBy.ID,'com.jhss.youguu:id/bar_name')
    '''输入标题'''
    title_content = (AppiumBy.ID, 'com.jhss.youguu:id/title_content')
    '''输入正文'''
    edit_content = (AppiumBy.ID, 'com.jhss.youguu:id/edit_content')
    '''点击发布'''
    # title_right_button1 = (AppiumBy.XPATH, '//android.widget.Button[@text="发布"]')
    title_right_button = (AppiumBy.ID, 'com.jhss.youguu:id/title_right_button')
    '''断言昵称'''
    TextView=AppiumBy.XPATH,'//android.widget.TextView[@text="凌晨诉说心事"]'

    def Posting(self,title,connect):
        ''''点击聊股'''
        self.click_ele(self.btn_desktop_talk)
        '''点击铅笔'''
        self.click_ele(self.iv_public_twitter)
        '''点击优顾大家谈'''
        self.tap(53,898)
        '''输入标题'''
        self.send_keys(self.title_content,title)
        sleep(2)
        '''输入正文'''
        self.send_keys(self.edit_content,connect)
        sleep(2)
        '''点击发布'''
        self.click_ele(self.title_right_button)
        sleep(2)
        #刷新
        self.swip_down(1)
